package net.zelenay.jcrviewer;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import com.apple.eawt.Application;
import com.apple.eawt.ApplicationAdapter;
import com.apple.eawt.ApplicationEvent;

/**
 * 
 * @author Peter Zelenay
 * 
 */
public class MainOSX extends ApplicationAdapter {

	private final Application application = new Application();

	private MainOSX() {
		System.setProperty("apple.laf.useScreenMenuBar", "true");
		System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
		application.addApplicationListener(this);
		application.setEnabledAboutMenu(true);
		application.setEnabledPreferencesMenu(true);
	}

	public static final void main(String[] args) {
		new MainOSX();
		Main.main(args);
	}

	@Override
	public void handleQuit(ApplicationEvent event) {
		// event.setHandled(false);
		int option = JOptionPane.showConfirmDialog(new JFrame(), "Are you sure you want to quit?", "Quit?",
				JOptionPane.YES_NO_OPTION);
		if (option == JOptionPane.YES_OPTION) {
			System.exit(0);
		}
	}

}
